//
//  PTStuLSReleaseDetailContentCell.m
//  PlanTech
//  发布详情-内容区域
//  Created by ruifeng song on 2018/7/12.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "PTStuLSReleaseDetailContentCell.h"
#import "SINACalendarUtils.h"

@interface PTStuLSReleaseDetailContentCell()

@property(nonatomic,strong)UILabel * statusNameLabel;
@property(nonatomic,strong)UILabel * receiveNameLabel;
@property(nonatomic,strong)UILabel * serviceTypeLabel;
@property(nonatomic,strong)UILabel * phoneLabel;
@property(nonatomic,strong)UILabel * addressTitlelabel;
@property(nonatomic,strong)UILabel * userAddressLabel;
@property(nonatomic,strong)UILabel * timeLabel;
@property(nonatomic,strong)UILabel * remarkLabel;
@property(nonatomic,strong)UILabel * remarkNameLabel;
@property(nonatomic,strong)UIView * backView;

@end

@implementation PTStuLSReleaseDetailContentCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        _backView = [[UIView alloc]initWithFrame:CGRectMake(12, 10, ScreenWidth -24, 195)];
        _backView.layer.cornerRadius = 6;
        _backView.layer.masksToBounds = YES;
        _backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_backView];
        
        _receiveNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,20,ScreenWidth - 40 - 24, 12)];
        _receiveNameLabel.text = @"收货人：张改呀";
        _receiveNameLabel.font = PTFONT_12;
        _receiveNameLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_receiveNameLabel];
        
        _statusNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(_backView.width - 70,20,50, 15)];
        _statusNameLabel.text = @"待接单";
        _statusNameLabel.font = PTFONT_15;
        _statusNameLabel.textColor = PTColor_349ef7;
        [_backView addSubview:_statusNameLabel];
        
        _serviceTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,_receiveNameLabel.bottom + 13, _receiveNameLabel.width, 12)];
        _serviceTypeLabel.text = @"服务类型：超市代购";
        _serviceTypeLabel.font = PTFONT_12;
        _serviceTypeLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_serviceTypeLabel];
        
        _addressTitlelabel = [[UILabel alloc]initWithFrame:CGRectMake(20,_serviceTypeLabel.bottom + 13, 62, 12)];
        _addressTitlelabel.text = @"收货地址：";
        _addressTitlelabel.font = PTFONT_12;
        _addressTitlelabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_addressTitlelabel ];
        
        _userAddressLabel = [[UILabel alloc]initWithFrame:CGRectMake(_addressTitlelabel.right,_serviceTypeLabel.bottom  +12, _serviceTypeLabel.width - 62, 12)];
//        _userAddressLabel.text = @"某年某日某天地址地址地址地址地址地址地址";
        _userAddressLabel.font = PTFONT_12;
        _userAddressLabel.numberOfLines = 5;
        _userAddressLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_userAddressLabel];
        
        _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,_userAddressLabel.bottom +11, _serviceTypeLabel.width, 12)];
        _timeLabel.text = @"收货时间：10:00-12:00";
        _timeLabel.font = PTFONT_12;
        _timeLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_timeLabel ];
        
        _phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,_timeLabel.bottom + 13, _timeLabel.width, 12)];
        _phoneLabel.text = @"联系电话：18888888888";
        _phoneLabel.font = PTFONT_12;
        _phoneLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_phoneLabel ];
        
        _remarkNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,_phoneLabel.bottom + 13, 40, 12)];
        _remarkNameLabel.text = @"备注：";
        _remarkNameLabel.font = PTFONT_12;
        _remarkNameLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_remarkNameLabel];
        
        _remarkLabel = [[UILabel alloc]initWithFrame:CGRectMake(_remarkNameLabel.right,_phoneLabel.bottom + 12, _phoneLabel.width - 40, 12)];
//        _remarkLabel.text = @"什么事没什么什么事没什么什么什么什么什么什么什打大萨达所大所大萨达撒大所大萨达撒大所大声道撒";
        _remarkLabel.font = PTFONT_12;
        _remarkLabel.numberOfLines = 5;
        _remarkLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_remarkLabel];
        
    }
    return self;
}

-(void)updateMyReleaseDetailContentCellWith:(LifeServiceListDetailModel *)detailModel
{
    
    if (detailModel == nil) {
        return;
    }
    self.receiveNameLabel.text = [NSString stringWithFormat:@"收货人：%@",detailModel.userName];
    
    NSString * serviceType = nil;
    switch ([detailModel.type integerValue]) {
        case PTLifeService_ExpressType:
            serviceType = @"代取快递";
            break;
        case PTLifeService_PrintType:
        {
            serviceType = @"打印复印";
        }
            break;
        case PTLifeService_BuyMealType:
            serviceType = @"捎饭带饭";
            break;
        case PTLifeService_HotboomType:
            serviceType = @"超市代购";
            break;
    }
    
    self.serviceTypeLabel.text = [NSString stringWithFormat:@"服务类型：%@",serviceType];
    self.phoneLabel.text= [NSString stringWithFormat:@"联系电话：%@",detailModel.userPhone];
    
    self.userAddressLabel.text= detailModel.userAddress;
    
    //收货地址动态高度：
    CGFloat addressHeight = [self.userAddressLabel.text heightForFont:self.userAddressLabel.font width:_userAddressLabel.width];
    [self.userAddressLabel setFrame:CGRectMake(self.addressTitlelabel.right,self.serviceTypeLabel.bottom + 12, self.serviceTypeLabel.width - 62, addressHeight)];
    
    switch ([detailModel.status integerValue]) {
        case PTLifeService_NormalStatus:
        {
            self.statusNameLabel.text = @"待接单";
        }
            break;
        case PTLifeService_CancelReleaseStatus:
        {
            self.statusNameLabel.text = @"已取消";
        }
            break;
        case PTLifeService_TakeOrderUnDoneStatus:
        {
            self.statusNameLabel.text = @"已接单";
        }
            break;
        case PTLifeService_TakeOrderDoneStatus:
        {
            self.statusNameLabel.text = @"待完成";
        }
            break;
        case PTLifeService_CommentStatus:
        {
            self.statusNameLabel.text = @"已评价";
        }
            break;
        case PTLifeService_FinishStatus:
        {
            self.statusNameLabel.text = @"待评价";
        }
            break;
        case PTLifeService_WaitSolveStatus:
        {
            self.statusNameLabel.text = @"待处理";
        }
            break;
    }
    
    NSString *startimeStr=[NSString stringWithFormat:@"%@",detailModel.startTime];
    NSString *endTimeStr=[NSString stringWithFormat:@"%@",detailModel.endTime];
    
    self.timeLabel.text = [NSString stringWithFormat:@"收货时间：%@-%@",[SINACalendarUtils getDateStringWithTimeStr:startimeStr andFormat:@"MM月dd日 HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:endTimeStr andFormat:@"HH:mm"]];
    [self.timeLabel setFrame:CGRectMake(20, self.userAddressLabel.bottom + 11, self.serviceTypeLabel.width, 12)];
    
    [self.phoneLabel setFrame:CGRectMake(20,self.timeLabel.bottom + 13, self.timeLabel.width, 12)];
    
    [self.remarkNameLabel setFrame:CGRectMake(20,self.phoneLabel.bottom + 13, 40, 12)];
    
     self.remarkLabel.text = detailModel.remark;
    
    //备注内容动态高度：
    CGFloat remarkHeight = [self.remarkLabel.text heightForFont:self.remarkLabel.font width:self.remarkLabel.width];
    [self.remarkLabel setFrame:CGRectMake(self.remarkNameLabel.right,self.phoneLabel.bottom  +12, self.phoneLabel.width - 40, remarkHeight)];
    
    [self.backView setFrame:CGRectMake(12, 10, ScreenWidth - 24, remarkHeight + addressHeight + 40 + 100)];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
